<template>
  <v-plain-dialog ref="audit">
    <el-form label-width="220px" label-position="right">
      <v-form-title title="证件信息"/>
      <div class="images">
        <div v-for="img in currentMember.images" :key="img.src" class="item">
          <p>{{img.name}}</p>
          <div class="bd">
            <img :src="img.src" alt="" @click="previewImage(img.src)">
          </div>
        </div>
      </div>
      <el-form-item label="社会统一代码证" v-if="currentMember.certType === 1">
        {{currentMember.socialCreditCode}}
      </el-form-item>
      <el-form-item label="营业执照注册号" v-if="currentMember.certType !== 1">
        {{currentMember.businessLicenseNumber}}
      </el-form-item>
      <el-form-item label="组织机构代码证" v-if="currentMember.certType !== 1">
        {{currentMember.organizationCode}}
      </el-form-item>
      <v-form-title title="企业信息"/>
      <el-form-item label="企业名称">{{currentMember.enterpriseName}}</el-form-item>
      <el-form-item label="法人姓名">{{currentMember.legalRepresentative}}</el-form-item>
      <el-form-item label="法人身份证号码">{{currentMember.legalCertNo}}</el-form-item>
      <el-form-item label="详细地址">{{currentMember.address}}</el-form-item>
      <el-form-item label="行业类型">{{$utils.toTypeFormat(currentMember.industryType,$dict.industryTypes)}}
      </el-form-item>
      <el-form-item label="企业类型">{{$utils.toTypeFormat(currentMember.enterpriseType,$dict.enterpriseTypes)}}
      </el-form-item>
      <el-form-item>
        <el-button size="small" type="primary" @click="audit(currentMember.enterpriseUserId,0)">通过</el-button>
        <el-button size="small" @click="audit(currentMember.id,1)">驳回</el-button>
      </el-form-item>

    </el-form>
  </v-plain-dialog>
</template>

<script lang="ts">
  import { Vue, Component } from 'vue-property-decorator'
  import vPlainDialog from '@/components/plain-dialog'
  import vFormTitle from '@/components/form-title'

  @Component({
    components: {
      vPlainDialog,
      vFormTitle
    }
  })
  export default class Merchants extends Vue {
    currentMember = {
      channelName: '',
      address: '',
      industryType: 1,
      enterpriseType: 1,
      certType: 1
    }

    previewImage (src) {
      window.open(src)
    }

    async audit (enterpriseUserId, reviewResults) {
      let res: AjaxResponse = await this.$axios.post('b/boms/member/reviewenterpriseinfo', {
        enterpriseUserId, reviewResults,
      })
      this.$utils.tips(res)
      if (res.responseCode === 200) {
        this.$refs.audit.closeDialog()
        this.$emit('initList')
      }
    }

    openDialog (channelProvider) {
      this.currentMember = channelProvider
      this.currentMember.images = [
        {
          name: '营业执照正本',
          src: this.currentMember.businessLicensePhoto
        },
        {
          name: '法人身份证正面',
          src: this.currentMember.legalFrontPhoto
        },
        {
          name: '法人身份证背面',
          src: this.currentMember.legalBackPhoto
        },
        {
          name: '组织机构代码',
          src: this.currentMember.organizationCodePhoto
        },
        {
          name: '统一社会信用代码',
          src: this.currentMember.taxRegistrationPhoto
        }
      ].filter(v => v.src)
      this.$refs.audit.openDialog()
    }
  }
</script>

<style lang="less" scoped>
  .images {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
    .item {
      width: 210px;
      text-align: center;
      .bd {
        border: 1px solid #ddd;
        padding: 10px 0;
      }

      img {
        width: 180px;
        height: 148px;
      }
    }

    p {
      font-size: 16px;
      color: #666666;
      text-align: center;
      padding-bottom: 20px;
    }
  }
</style>
